package com.example.boot.modules.system.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.boot.modules.system.dto.UserParam;
import com.example.boot.modules.system.entity.User;
import com.example.boot.modules.system.entity.UserDeptJoin;
import com.example.boot.modules.system.entity.UserRoleJoin;
import com.example.boot.modules.system.vo.UserVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *
 * @author 王令
 * @since 2022-08-05
 */
public interface UserMapper extends BaseMapper<User> {

    void addWithRoleJoins(@Param("userId") Long userId, @Param("rolesId") List<Long> rolesId);

    void addWithDeptJoins(@Param("userId") Long userId, @Param("deptsId") List<Long> deptsId);

    void removeWithRoleJoins(Long id);

    void removeWithDeptJoins(Long id);

    UserVo findUserVoById(Long id);

    @InterceptorIgnore(tenantLine = "true")
    User findByTenantIdAndUsername(@Param("tenantId") String tenantId, @Param("username") String username);

    Page<UserVo> listWithPagination(IPage<User> page, @Param("param") UserParam param);

    List<UserRoleJoin> listWithRoleJoinByUserId(Long userId);

    List<UserDeptJoin> listWithDeptJoinByUserId(Long userId);

}
